package cool.taomu.toolkit.dbutils.test

import com.google.inject.Key
import cool.taomu.toolkit.Taomu
import cool.taomu.toolkit.annotations.datasource.Primary
import javax.inject.Inject
import javax.sql.DataSource
import org.junit.jupiter.api.Test
import cool.taomu.toolkit.dbutils.DbUtils

class JooqTest {

    @Inject
    DbUtils dsl

    @Test
    def void a() {
        var inject = Taomu.run()
        var test = inject.getInstance(Key.get(DataSource, Primary))
        var testj = inject.getInstance(JooqTest)
        if (test !== null) {
            var sql = "select count(1) from taomu_stock_history";
            var result = testj.dsl.queryMap(sql)
            System.out.println("result: " + result);
        } else {
            println("DataSource = null")
        }
    }
}
